package com.ys.service.Impl;

import com.ys.mapper.DrugsMapper;
import com.ys.mapper.DrugssMapper;
import com.ys.pojo.Drugs;
import com.ys.pojo.Drugss;
import com.ys.service.DrugssService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("drugssService")
public class DrugssServiceImpl implements DrugssService {
    @Resource
    private DrugssMapper drugssMapper;
    @Override
    public int addsinsert(Drugss drugss) {
        return drugssMapper.addsinsert(drugss);
    }

    @Override
    public List<Drugss> list(String ids) {
        return drugssMapper.select(ids);
    }


    /**
     * 根据订单号查询
     * @param orderId
     * @return
     */
    @Override
    public List<Drugss> searchOrderId(Integer orderId) {
        return drugssMapper.findAll(orderId);
    }

    @Override
    public boolean Warehousing(Drugss[] drugsses, Integer orderId) {
        try {
            for (int i = 0; i <drugsses.length ; i++) {
                drugssMapper.updDrugsNumber(drugsses[i]);
            }
            drugssMapper.updQualState(orderId);
        } catch (Exception e) {
            return false;
        }
        return true;
    }
}
